package weibo4android.androidexamples;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.widget.ImageView;

public class LogoActivity extends Activity {
    private ImageView logo_image;
    private String token;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
		setContentView(R.layout.logo);
		
		logo_image=(ImageView) this.findViewById(R.id.logo_image);
		AlphaAnimation animation=new AlphaAnimation(0.1f, 1.0f);
		animation.setDuration(3000);
		logo_image.setAnimation(animation);
		SharedPreferences preferences = getSharedPreferences("ss",
				Context.MODE_PRIVATE);
		 token = preferences.getString("token", "");
		 
		animation.setAnimationListener(new AnimationListener() {
			
			@Override
			public void onAnimationStart(Animation animation) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void onAnimationRepeat(Animation animation) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void onAnimationEnd(Animation animation) {
				// TODO Auto-generated method stub
				if (null == token || "".equals(token)) {
					Intent intent = new Intent(LogoActivity.this,LoginActivity.class);
					startActivity(intent);
				}else{
					Intent intent = new Intent(LogoActivity.this,
							LoginActivity.class);
					intent.putExtra("isHave", true);
					startActivity(intent);
				}
				finish();
			}
			
		});
	}
}
